package com.lfg.leetcode.leetcode2000;


import java.util.ArrayList;
import java.util.List;

public class No2100goodDaysToRobBank {
    public static void main(String[] args) {
        System.out.println(goodDaysToRobBank(new int[]{
                5,3,3,3,5,6,2
        }, 2));

    }

    public static List<Integer> goodDaysToRobBank(int[] security, int time) {
        int[] left = new int[security.length];
        int[] right = new int[security.length];
        for (int i = 1; i < security.length; i++) {
            if (security[i] <= security[i - 1]) {
                left[i] = left[i - 1] + 1;
            }
        }
        for (int i = security.length - 2; i >= 0; i--) {
            if (security[i] <= security[i+1]) {
                right[i] = right[i + 1] + 1;
            }
        }
        List<Integer> ret = new ArrayList<>(security.length);
        for (int i = time; i < security.length-time; i++) {
            if (left[i] >= time && right[i] >= time) {
                ret.add(i);
            }
        }
        return ret;
    }
}



